<?php

namespace App\Http\Controllers\Reception;
use Illuminate\Http\Request;
use App\Tables\admin_users;
use App\Http\Controllers\Controller;
use\App\Http\Middleware\CrossHttp;
use Illuminate\Support\Facades\Hash;
class adminUsers extends Controller
{
    //
    public function post_user_data(Request $request){
    	$add = new admin_users;
        $add->admin_name = $request->name;
        $add->tele = $request->tele;
        $pw =Hash::make($request->password);
        $add->admin_password= $pw;
        $add->save();
		// try{
		//  var_dump($add);
		//   }catch (\Exception $e){
		//  var_dump($e)；
		// }
        return  "成功";
    }
    public function view_admin_users(){
    	$view_admin= admin_users::all();
    	return $view_admin;

    }

    public function delete_admin_user($id){
        $delete = admin_users::where('id',$id)->delete();
        return $delete ;
    }
    public function select_admin_user($per){
    	$per =trim($per);
    	$select =admin_users::where('admin_name','like','%'.$per.'%')->get();
    	return $select;
    }
    public function put_admin_user($id,Request $request){
    	//$obj = $str->toJson();
    	// $obj = JSON.parse($str);
    	$name=$request->name;
    	$tele=$request->tele;
    $put =admin_users::where('id',$id)->update(['admin_name'=>$name,'tele'=>$tele]);
    	return $id;
    }
}
